﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace CSharpStudyConsole
{
    public class HttpOpeate
    {
        public HttpOpeate()
        {

        }
        public static string GetUrlToHtml(string url, Encoding encoding)
        {

            try
            {
                WebRequest webrequest = WebRequest.Create(url);
                WebResponse webresponse = webrequest.GetResponse();
                Stream stream = webresponse.GetResponseStream();
                using (StreamReader reader = new StreamReader(stream, encoding))
                {
                    return reader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
    }
}
